package com.itheima.bigevent.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class User {
    /**
     * 主键ID
     */
    @NotNull(message = "id不能为空", groups = {Update.class})
    private Integer id;
    /**
     * 用户名
     */
    @NotNull(message = "用户名不能为空")
    @Pattern(message = "用户名只能是5至16位的非空字符", regexp = "^\\S{5,16}$")
    private String username;
    /**
     * 密码
     */
    @NotNull(message = "密码不能为空")
    @Pattern(message = "密码只能是5至16位的非空字符", regexp = "^\\S{5,16}$")
    @JsonIgnore
    private String password;
    /**
     * 昵称
     */
    @NotEmpty(message = "昵称不能为空", groups = {Update.class})
    @Pattern(message = "昵称只能是1至10位的非空字符", regexp = "^\\S{1,10}$", groups = {Update.class})
    private String nickname;
    /**
     * 邮箱
     */
    @NotEmpty(message = "邮箱不能位空", groups = {Update.class})
    @Email(message = "邮箱格式不正确", groups = {Update.class})
    private String email;
    /**
     * 用户头像地址
     */
    private String userPic;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    public interface Update {

    }

    public interface Save{}
}
